/*
 *  Copyright (C) 2011 Jesus Navalon i Pastor <jnavalon at redhermes dot net>
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * pn_Info.java
 *
 * Created on 13/03/2011, 16:27:36
 */

package kuasar.plugin.utils;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 *
 * @author Jesus Navalon i Pastor <jnavalon at redhermes dot net>
 */
public class pn_Info extends kuasar.plugin.classMod.AbstractPanel {

    private JPanel current;
    private JPanel cont;
    public static final int ICON_INFO = 0;
    public static final int ICON_WARNING = 1;
    public static final int ICON_WAIT = 2;
    public static final int ICON_ERROR = 3;
    public static final int ICON_FORBIDDEN = 4;

    /** Creates new form pn_Info */
    private pn_Info(JPanel cont, JPanel current, String title, String info, int type) {
        this.current=current;
        this.cont = cont;
        initComponents();
        lbl_Title.setText(title);
        lbl_Info.setText("<html><body>"+info+"</body></html>");
        ImageIcon icon = null;
        switch(type){
            case 0:
                icon= new ImageIcon(getClass().getResource("/kuasar/plugin/icons/dialog-information.png"));
                break;
            case 1:
                icon = new ImageIcon(getClass().getResource("/kuasar/plugin/icons/dialog-warning.png"));
                break;
            case 2:
                 icon = new ImageIcon(getClass().getResource("/kuasar/plugin/icons/dialog-wait.png"));
                 break;
            case 3:
                 icon = new ImageIcon(getClass().getResource("/kuasar/plugin/icons/dialog-error.png"));
                 break;
            case 4:
                 icon = new ImageIcon(getClass().getResource("/kuasar/plugin/icons/dialog-forbidden.png"));
                 break;
        }
        lbl_Title.setIcon(icon);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbl_Title = new javax.swing.JLabel();
        lbl_Info = new javax.swing.JLabel();
        btn_OK = new javax.swing.JButton();

        setOpaque(false);

        lbl_Title.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
        lbl_Title.setForeground(new java.awt.Color(204, 204, 204));
        lbl_Title.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kuasar/plugin/icons/dialog-information.png"))); // NOI18N
        lbl_Title.setText("<Text Here>");

        lbl_Info.setForeground(new java.awt.Color(204, 204, 204));
        lbl_Info.setText("<Info Here>");
        lbl_Info.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        btn_OK.setText("OK");
        btn_OK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_OKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(84, 84, 84)
                        .addComponent(lbl_Info, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lbl_Title, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(335, Short.MAX_VALUE)
                        .addComponent(btn_OK)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_Title, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_Info, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_OK)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btn_OKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_OKActionPerformed
        cont.removeAll();
        cont.add(current);
        current.setBounds(0, 0, cont.getWidth(), cont.getHeight());
        cont.updateUI();
    }//GEN-LAST:event_btn_OKActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_OK;
    private javax.swing.JLabel lbl_Info;
    private javax.swing.JLabel lbl_Title;
    // End of variables declaration//GEN-END:variables

    public static void Load(JPanel cont, JPanel current, String title, String info, int type){
        pn_Info panel = new pn_Info(cont, current, title, info, type);
        cont.removeAll();
        panel.setBounds(0, 0, cont.getWidth(), cont.getHeight());
        cont.add(panel);
        panel.setVisible(true);
        panel.getFocus();
        cont.updateUI();
    }
    public void getFocus(){
        btn_OK.requestFocus();
    }
}
